#!/bin/bash

check_cpu() {
    echo "CPU 使用率："
    top -b -n1 | grep "Cpu(s)" | awk '{print $2 + $4}' | xargs echo "CPU 使用率为: %"
}

check_memory() {
    echo "内存使用情况："
    free -h | awk '/Mem:/ {print "已用: " $3 ", 可用: " $7}'
}

check_storage() {
    echo "存储使用情况："
    df -h --output=source,used,avail | grep "^/" | awk '{print $1 ": 已用 " $2 ", 可用 " $3}'
}

case "$1" in
    CPURESOURCECONSEME)
        check_cpu
        ;;
    MEMRESOURCECONSEME)
        check_memory
        ;;
    STORAGERESOURCECONSEME)
        check_storage
        ;;
    *)
        echo "用法: $0 CPURESOURCECONSEME | MEMRESOURCECONSEME | STORAGERESOURCECONSEME"
        ;;
esac
